package io.renren.modules.upk.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.upk.entity.UpkCategoryBrandEntity;
import io.renren.modules.upk.service.UpkCategoryBrandService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 商品类目和品牌关联表，保存商品类目和品牌的关联信息。
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-05-29 20:29:24
 */
@RestController
@RequestMapping("generator/upkcategorybrand")
public class UpkCategoryBrandController {
    @Autowired
    private UpkCategoryBrandService upkCategoryBrandService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("upk:upkcategorybrand:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = upkCategoryBrandService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
//    @RequiresPermissions("upk:upkcategorybrand:info")
    public R info(@PathVariable("id") Long id){
			UpkCategoryBrandEntity upkCategoryBrand = upkCategoryBrandService.selectById(id);

        return R.ok().put("upkCategoryBrand", upkCategoryBrand);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("upk:upkcategorybrand:save")
    public R save(@RequestBody UpkCategoryBrandEntity upkCategoryBrand){
			upkCategoryBrandService.insert(upkCategoryBrand);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("upk:upkcategorybrand:update")
    public R update(@RequestBody UpkCategoryBrandEntity upkCategoryBrand){
			upkCategoryBrandService.updateById(upkCategoryBrand);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("upk:upkcategorybrand:delete")
    public R delete(@RequestBody Long[] ids){
			upkCategoryBrandService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
